﻿using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using Runda.EShop.Common.Utility;
using Runda.EShop.Common.Entity;

namespace Runda.EShop.Dal
{
    /// <summary>
    /// DAL layer class dbo.Biz_Ent_Addr.
    /// </summary>
    public partial class BizEntAddrDal
    {
        public void UpdateAddressDefault(Guid ID,string IsDefault)
        {
            string sql = "update Biz_Ent_Addr set IsDefault = @Default WHERE ID = @ID";

            DbCommand dbcommand = CurrentDatabase.GetSqlStringCommand(sql);
            CurrentDatabase.AddInParameter(dbcommand, "@Default", DbType.String, IsDefault);
            CurrentDatabase.AddInParameter(dbcommand, "@ID", DbType.Guid, ID);

            CurrentDatabase.ExecuteNonQuery(dbcommand);
        }

        public void UpdateAddressNonDefault(Guid EntID)
        {
            string sql = "update Biz_Ent_Addr set IsDefault = 'N' WHERE EntID = @EntID and IsDefault='Y'";

            DbCommand dbcommand = CurrentDatabase.GetSqlStringCommand(sql);
            CurrentDatabase.AddInParameter(dbcommand, "@EntID", DbType.Guid, EntID);

            CurrentDatabase.ExecuteNonQuery(dbcommand);
        }
    }
}
